package handle

import (
	"fmt"
	"io"
	"net/http"
	"utils/tools/httpUtils"
)

func RequestBody(client *http.Client, url string) ([]byte, bool) {
	req := httpUtils.CreateReq(url, http.MethodGet, nil, func(req *http.Request) {
		req.Header.Add("User-Agent", "Apifox/1.0.0 (https://www.apifox.cn)")
		req.Header.Add("Accept", "*/*")
		req.Header.Add("Host", "store.steampowered.com")
		req.Header.Add("Connection", "keep-alive")
	})

	resp, err := client.Do(req)
	if err != nil {
		panic(resp.StatusCode)
		return nil, false
	}
	defer resp.Body.Close()
	respBytes, err := io.ReadAll(resp.Body)
	if err != nil {
		err = fmt.Errorf("read response data failed: %s", err.Error())
		panic("respBytes")
	}

	return respBytes, true
}
